<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>mktime</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_669">&nbsp;</a>NAME</h4><blockquote>
mktime - convert broken-down time into time since the Epoch
</blockquote><h4><a name = "tag_000_007_670">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="time.h.html">time.h</a>&gt;

time_t mktime(struct tm *<i>timeptr</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_671">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>mktime()</i>
function converts the broken-down time, expressed as local time,
in the structure pointed to by
<i>timeptr</i>,
into a time since the Epoch value with the same encoding as that of the
values returned by
<i><a href="time.html">time()</a></i>.
The original values of the
<i>tm_wday</i>
and
<i>tm_yday</i>
components of the structure are ignored, and the original values
of the other components are not restricted to the ranges
described in the
<i><a href="time.h.html">&lt;time.h&gt;</a></i>
entry.
<p>
A positive or 0 value for
<i>tm_isdst</i>
causes
<i>mktime()</i>
to presume initially that Daylight Savings Time, respectively, is or is not in
effect for the specified time.  A negative value for
<i>tm_isdst</i>
causes
<i>mktime()</i>
to attempt to determine whether Daylight Saving Time is
in effect for the specified time.
<p>
Local timezone information is set as though
<i>mktime()</i>
called
<i><a href="tzset.html">tzset()</a></i>.
<p>
Upon successful completion, the values of the
<i>tm_wday</i>
and
<i>tm_yday</i>
components of the structure are set appropriately, and the other
components are set to represent the specified time since the Epoch, but
with their values forced to the ranges indicated in the
<i><a href="time.h.html">&lt;time.h&gt;</a></i>
entry; the final value of
<i>tm_mday</i>
is not set until
<i>tm_mon</i>
and
<i>tm_year</i>
are determined.
</blockquote><h4><a name = "tag_000_007_672">&nbsp;</a>RETURN VALUE</h4><blockquote>
The
<i>mktime()</i>
function returns the specified time since the Epoch encoded as a value
of type
<b>time_t</b>.
If the time since the Epoch cannot be represented, the function returns
the value
(<b>time_t</b>)-1.
</blockquote><h4><a name = "tag_000_007_673">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_000_007_674">&nbsp;</a>EXAMPLES</h4><blockquote>
What day of the week is July 4, 2001?
<pre>
<code>
#include &lt;stdio.h&gt;
#include &lt;time.h&gt;

struct tm time_str;

char daybuf[20];

int main(void)
{
    time_str.tm_year = 2001 - 1900;
    time_str.tm_mon = 7 - 1;
    time_str.tm_mday = 4;
    time_str.tm_hour = 0;
    time_str.tm_min = 0;
    time_str.tm_sec = 1;
    time_str.tm_isdst = -1;
    if (mktime(&amp;time_str) == -1)
        (void)puts("-unknown-");
    else {
        (void)strftime(daybuf, sizeof(daybuf), "%A", &amp;time_str);
        (void)puts(daybuf);
    }
    return 0;
}
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_675">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_676">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_677">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="asctime.html">asctime()</a></i>,
<i><a href="clock.html">clock()</a></i>,
<i><a href="ctime.html">ctime()</a></i>,
<i><a href="difftime.html">difftime()</a></i>,
<i><a href="gmtime.html">gmtime()</a></i>,
<i><a href="localtime.html">localtime()</a></i>,
<i><a href="strftime.html">strftime()</a></i>,
<i><a href="strptime.html">strptime()</a></i>,
<i><a href="time.html">time()</a></i>,
<i><a href="utime.html">utime()</a></i>,
<i><a href="time.h.html">&lt;time.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the POSIX.1-1988 standard and ANSI C standard.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

